//
//  GWPlayMusicTool.m
//  QQ音乐
//
//  Created by qianfeng on 16/3/10.
//  Copyright © 2016年 高炜. All rights reserved.
//

#import "GWPlayMusicTool.h"
#import "GWMusic.h"
#import "MJExtension.h"
static NSArray *musics_;
static GWMusic *currentMusic_;
@implementation GWPlayMusicTool
+(void)initialize
{
    if (musics_==nil) {
        musics_ =[GWMusic objectArrayWithFilename:@"Musics.plist"];
        
    }
    if (currentMusic_==nil) {
        currentMusic_=musics_[arc4random_uniform((int)musics_.count)];
    }
}
+(NSArray *)musics
{
    return musics_;
}
+(GWMusic *)currentPlayingMusic
{
    return currentMusic_;
}
+(GWMusic *)nextMusic
{
    NSInteger index =[musics_ indexOfObject:currentMusic_];
    NSInteger nextIndex = ++index;
    if (nextIndex>=musics_.count) {
        nextIndex=0;
    }
    return musics_[nextIndex];
}
+(GWMusic *)previousMusic
{
    NSInteger index =[musics_ indexOfObject:currentMusic_];
    NSInteger previousIndex = --index;
    if (previousIndex<0) {
        previousIndex=musics_.count-1;
    }
    return musics_[previousIndex];
}
+(void)setCurrentMusicWithMusic:(GWMusic *)music
{
    currentMusic_ =music;
}
@end
